import React from 'react'
import {connect} from 'react-redux'
import { Form, Button, Radio, Row, Col } from 'antd'
import {messages} from "share/common";
const FormItem = Form.Item;
const RadioGroup = Radio.Group;

class FinancialAccount extends React.Component{
  constructor(props){
    super(props);
    this.state = {
      setOfBooks: '',
      saveLoading: false
    }
  }

  componentWillMount() {
    this.setState({setOfBooks: this.props.setOfBooks},() => {
      // this.getList();
    });
  }

  componentWillReceiveProps(nextProps) {
    this.setState({setOfBooks: nextProps.setOfBooks});
  }

  handleSave = () => {
    this.props.form.validateFieldsAndScroll((err,values) => {
      if(!err){
        console.log(values);
      }
    });
  };

  render(){
    const { saveLoading } = this.state;
    const { getFieldDecorator } = this.props.form;
    const formItemLayout = {
      labelCol: { span: 2 },
      wrapperCol: { span: 14, offset: 1 },
    };
    return(
      <div>
        <Form>
          <FormItem {...formItemLayout} label={messages('finance-setting.key25'/*会计期代码*/)} style={{marginBottom:'15px'}}>
            {getFieldDecorator('periodSetCode', {
              rules: [{
                required: true,
                message: messages('common.please.select')
              }],
              // initialValue: period ? period.periodSetCode : ''
            })(
              <RadioGroup>
                <Radio key={'audit'} value={'audit'}>{messages('finance-setting.key207')/*审核时产生费用帐*/}</Radio>
                <Radio key={'pay'} value={'pay'}>{messages('finance-setting.key208')/*付款时产生费用帐*/}</Radio>
              </RadioGroup>
            )}
          </FormItem>
          <div>
            <Row>
              <Col span={21} offset={3}>{messages('finance-setting.key209')/*付款时产生费用帐对后续的核算以及分期支付产生影响，请确认选择！*/}</Col>
            </Row>
          </div>
          <div style={{marginTop: '15px', fontSize: '20px', fontWeight: '900', color: 'rgba(0,0,0,0.25)'}}>
            <Row>
              <Col span={21} offset={3}>
                <Button type={'primary'} onClick={this.handleSave} loading={saveLoading}>{messages('common.save')/*保存*/}</Button>
              </Col>
            </Row>
          </div>
        </Form>
      </div>
    )
  }
}

function mapStateToProps(state){
  return {

  }
}

const WrappedFinancialAccount = Form.create()(FinancialAccount);
export default connect(mapStateToProps)(WrappedFinancialAccount);
